package com.ph.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@TableName("sys_user")
public class User implements Serializable {
    private static final long serialVersionUID = -3729396316250143381L;
    @TableId(type = IdType.AUTO)
    private Integer id;
    private String name;
    private Long phone;
    private String password;
    private String code;
    private Integer roleId;
    private String status;
    private String gender;
    private String email;
    private Integer departmentId;
    @TableField(exist = false)
    private String departmentName;
    @TableField(exist = false)
    private List<Role> roles;

    public  String getLabel(){
        return name;
    }

    public String getRoleName(){
        String content = "";
        if (roles != null && roles.size()>0){
            for (Role role : roles){
                content += role.getName()+",";
            }
            return content.substring(0,content.length()-1);
        }
        return content;
    }
}
